package com.bytech.common.biz.enums.comment;

import java.util.HashMap;
import java.util.Map;

import com.bytech.common.utils.StringUtils;
import lombok.Getter;

/**
 * @Author zhao
 * @Create 2021/8/4 16:14
 */
@Getter
public enum CommentTypeEnum {

    UNKNOWN("unknown", "未知"),
    MESSAGE("message", "留言"),
    COMMENT("comment", "评论"),
    ;

    private final String value;
    private final String desc;

    CommentTypeEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private static final Map<String, CommentTypeEnum> map = new HashMap<>(CommentTypeEnum.values().length);

    static {
        for (CommentTypeEnum e : CommentTypeEnum.values()) {
            map.put(e.value, e);
        }
    }

    public static CommentTypeEnum of(String type) {
        if (StringUtils.isBlank(type)) {
            return UNKNOWN;
        }
        return map.get(type) == null ? UNKNOWN : map.get(type);
    }
}
